home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
term
/
trms20d.lha
/
ScriptFiles.lha
/
ScriptDemo.scp
< prev
next >
Wrap
Text File
|
1993-11-14
|
21KB
|
1,069 lines
/* $VER: Terminus 2.0c - ScriptDemo.scp (20.09.93) */
/*
** Copyright (C) 1992-3, John P. Radigan, All Rights Reserved, Worldwide.
**
** This script demonstrates most all commands and functions present
** in the Terminus script language.
**
*/
dtpen = tpen
dbpen = bpen
titlebar = off
titlestatus = off
top:
cls
print local " ScriptDemo menu\n ---------------"
print local " 1. Operator precedence."
print local " 2. Integer functions."
print local " 3. String functions."
print local " 4. FOR loop."
print local " 5. WHILE loop."
print local " 6. REPEAT loop."
print local " 7. 200 GOTO's."
print local " 8. ONCARRIER, ONMOUSE and ONTIMEOUT."
print local " 9. CLRRECT, CLRLINE, INVLINE and GETLINE$."
print local " A. GETINT, GETSTRING."
print local " B. TIMER, DATE$, TIME$, TRACE."
print local " 0. Exit."
ask local "\n Enter number to perform ", i$
if i$ == "1"
gosub oporder
goto top
endif
if i$ == "2"
gosub ifuncdemo
goto top
endif
if i$ == "3"
gosub sfuncdemo
goto top
endif
if i$ == "4"
gosub fordemo
goto top
endif
if i$ == "5"
gosub whiledemo
goto top
endif
if i$ == "6"
gosub repeatdemo
goto top
endif
if i$ == "7"
gosub gotodemo
goto top
endif
if i$ == "8"
gosub ondemo
goto top
endif
if i$ == "9"
gosub linedemo
goto top
endif
if i$ == "A" OR i$ == "a"
gosub getdemo
goto top
endif
if i$ == "B" OR i$ == "b"
gosub datedemo
goto top
endif
if i$ == "0"
tpen = dtpen
bpen = dbpen
cls
print local "End Terminus script demo.\n"
end
endif
print local "\nUnknown menu item."
pause 1
goto top
oporder:
cls
print local " The following shows the expression to be passed to the parser, the"
print local "correct answer and the parser result.\n"
print local "-8 * 3 + 4 * 7 = 4",,, -8 * 3 + 4 * 7
print local "36 / 4 * 7 + 1 = 64",,, 36 / 4 * 7 + 1
print local "10 - 6 * -2 - 5 = 17",,, 10 - 6 * -2 - 5
print local "((((3 * 6) / 4) % 5) + 7) * 8 = 88", ((((3 * 6) / 4) % 5) + 7) * 8
print local "80 / (-7 - 3) * 3 = -24",,, 80 / (-7 - 3) * 3
gosub anykey
print local " The following show logical expression results in the same format.\n"
print local "10 != 12 = 1",,, 10 != 12
print local "10 AND 8 = 8",,, 10 AND 8
print local "10 OR 5 = 15",,, 10 OR 5
print local "9 XOR 8 = 1",,, 9 XOR 8
print local "3 XOR NOT 6 AND 15 = 10",, 3 XOR NOT 6 AND 15
gosub anykey
print local " And now for a mixed conditional, the expression to be evaluated is:\n"
print local " \"string\" != \"String\" AND 12 < 24 AND (7 == (NOT 7) OR 14 == (7 * 2))\n"
if "string" != "String" AND 12 < 24 AND (7 == (NOT 7) OR 14 == (7 * 2))
print local "Expression evaluated as TRUE."
else
print local "Expression evaluated as false."
endif
goto anykey
fordemo:
cls
i = 0
j = 0
print local "FOR I = 1 TO 20 demo...\n"
for i = 1 to 20
print local " "; i;
next
print local
gosub anykey
print local "FOR I = 1 TO 20 STEP 2 demo...\n"
for i = 1 to 20 step 2
print local " "; i;
next
print local
gosub anykey
print local "FOR I = 20 TO 0 STEP -2 demo...\n"
for i = 20 to 0 step -2
print local " "; i;
next
print local
gosub anykey
print local "NESTED FOR demo...\n"
for i = 1 to 10
for j = 1 to 10
print local " "; i;
next
print local
next
goto anykey
whiledemo:
cls
print local "WHILE loop conditional.\n"
i = 0
while i < 10
i = i + 1
print local " "; i;
wend
print local
gosub anykey
cls
print local "Nested WHILE loop conditional.\n"
i = 0
while i < 10
j = 0
while j < 10
j = j + 1
print local " "; j;
wend
print local
i = i + 1
wend
print local
goto anykey
repeatdemo:
cls
print local "REPEAT loop conditional.\n"
i = 0
repeat
i = i + 1
print local " "; i;
until i < 10
print local
gosub anykey
cls
print local "Nested REPEAT loop conditional.\n"
i = 0
repeat
j = 0
repeat
j = j + 1
print local " "; j;
until j < 10
print local
i = i + 1
until i < 10
print local
goto anykey
ifuncdemo:
cls
print local "ABS().\n"
print local "The absolute value of 30 - 50 is: ", ABS(30 - 50)
gosub anykey
print local "ASC().\n"
print local "ASCII value of the character 'A': ", ASC("A")
gosub anykey
print local "INSTR(), variation 1.\n"
print local "The position of substring TESTER in string SUBTEST is: ", INSTR("SUBTEST", "TESTER")
gosub anykey
print local "INSTR(), variation 2.\n"
print local "The position of substring TEST in string SUBTESTERED is: ", INSTR(2, "SUBTESTERED", "TEST")
gosub anykey
print local "INSTR(), variation 3.\n"
print local "The position of substring TEST in string SUBTEST is: ", INSTR("SUBTEST", "TEST")
gosub anykey
print local "LEN().\n"
print local "The length of string LONGSTRING is: ", LEN("LONGSTRING")
gosub anykey
print local "VAL().\n"
print local "The value of string 234 is: ", val("234")
goto anykey
sfuncdemo:
cls
print local "CHR$().\n"
print local "The character for ASCII value 65 is: ", chr$(65)
gosub anykey
print local "LEFT$().\n"
print local "The leftmost 5 characters of TESTSTRING is: ", left$("TESTSTRING", 5)
gosub anykey
print local "LOWER$().\n"
print local "The lowercase version of TESTSTRING is: ", lower$("TESTSTRING")
gosub anykey
print local "MID$().\n"
print local "The 5 char string starting at position 5 of TESTSTRING is: ", mid$("TESTSTRING", 5, 5)
gosub anykey
print local "RIGHT$().\n"
print local "The rightmost 5 characters of TESTSTRING is: ", right$("TESTSTRING", 5)
gosub anykey
print local "SPACE$().\n"
print local "The length of SPACE$(10) is: ", len(space$(10))
gosub anykey
print local "STR$().\n"
print local "The string of the value 234 is: ", str$(234)
gosub anykey
print local "TRIM$().\n"
print local "The trimmed length of \"TESTSTRING \" is: ", len(trim$("TESTSTRING "))
gosub anykey
print local "UPPER$().\n"
print local "The uppercase version of teststring is: ", upper$("teststring")
goto anykey
ondemo:
cls
print local " The ONCARRIER demo requires a modem to be attached to the serial port and"
print local "to be able to set carrier with the command AT&C0. The modem will then be"
print local "sent the command ATZ to reset the modem and drop carrier which will result"
print local "in the ONCARRIER command being executed.\n"
ask local "Continue [Y]/n? ", i$
print local
if trim$(upper$(i$)) == "N"
goto ondemo1
endif
oncarrier
ontimeout goto no_modem
send "at&c0^m"
wait 3, "OK"
ontimeout
oncarrier goto dcd
wait 1
send "atz^m"
wait 3
print local "ONCARRIER failed test.\n"
goto ondemo1
no_modem:
print local "Modem didn't respond, skipping test.\n"
goto ondemo1
dcd:
wait 1
print local "ONCARRIER passed test.\n"
ondemo1:
oncarrier
gosub anykey
cls
print local " The ONMOUSE demo will show an '@' at the location where the mouse pointer"
print local "is at when you click the left mouse button.\n"
onmouse goto mouseclick
print local "Move mouse and click left button when ready\n"
wait 10
print local "ONMOUSE failed.\n"
goto ondemo2
mouseclick:
print local "Mouse row: " mrow " Mouse col: " mcol "\n"
srow = row
scol = col
move mrow, mcol
bpen = 3
print local "@"
bpen = dbpen
move srow, scol
ondemo2:
onmouse
gosub anykey
cls
print local " The ONTIMEOUT demo will issue a WAIT command for one second, results will"
print local "be posted below.\n"
ontimeout goto gottimeout
wait 1, "NONSENSESTRING"
print local "ONTIMEOUT failed."
goto ondemo3
gottimeout:
print local "ONTIMEOUT passed."
ondemo3:
ontimeout
goto anykey
linedemo:
cls
print local "\n The following demo will fill rows 10 through 22 with the letter 'E' and"
print local "then clear a rectangle starting at position 11, 21 to 21, 58.\n"
move 9, 1
tpen = 2
for i = 1 to 80
print local i % 10;
next
tpen = 3
print local
move 10, 1
for i = 10 to 22
move i, 1
print local "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
next
tpen = dtpen
for i = 10 to 22
move i, 1
print local i;
next
print local
bpen = 3
clrrect 11, 21, 21, 58
bpen = dbpen
gosub anykey
cls
print local " The CLRLINE demo will print a line of 'E' characters at row 4 and will clear"
print local "a 20 character section starting at column 40.\n"
move 6, 1
for i = 1 to 80
print local i % 10;
next
move 7, 1
print local "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
move 7, 40
bpen = 3
clrline 20
bpen = dbpen
move 9, 1
gosub anykey
cls
print local " The INVLINE demo will print a line of 'E' characters at line 4 in inverse"
print local "colors then will reinvert a 20 character section starting at column 30.\n"
move 6, 1
for i = 1 to 80
print local i % 10;
next
move 7, 1
tpen = 2
bpen = 3
print local "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
tpen = 3
bpen = 2
move 7, 30
invline 20
move 9, 1
tpen = dtpen
bpen = dbpen
gosub anykey
cls
print local " The GETLINE$() demo lists some sample files and then inverts the middle line."
print local "The same line will be printed below the list to indicate that the GETLINE$()"
print local "worked.\n"
move 8,1
print local " FILENAME DATE SIZE"
print local " ----------------------------"
print local " test.LZH 1/2/89 72323"
print local " PIC.ZIP 2/12/90 23232"
print local " DOC.ARC 12/30/91 97687"
move 11, 1
invline
test$ = getline$(11)
move 15, 1
print local test$
goto anykey
getdemo:
cls
x$ = "Sample string"
print local "GETSTRING Demo."
GETSTRING "GETSTRING Demo", x$
print local "you entered: "; x$
x = 500
GETINT "GETINT Demo", x, 100, 1000
print local "you entered: "; x
goto anykey
datedemo:
cls
print local "TRACE, DATE$, TIME$ and TIMER demo."
TRACE = ON
print local "Current timer value is: "; TIMER
print local "Setting timer value to 86399"
TIMER = 86399
print local "Today's date is: "; DATE$
print local "The current time is: "; TIME$
TRACE = OFF
goto anykey
gotodemo:
cls
print local " This demo does 200 consecutive GOTO commands in a worst case situation.\n"
goto start
start200:
goto anykey
start199:
print local "10"
goto start200
start198:
print local "9 ";
goto start199
start197:
print local "8 ";
goto start198
start196:
print local "7 ";
goto start197
start195:
print local "6 ";
goto start196
start194:
print local "5 ";
goto start195
start193:
print local "4 ";
goto start194
start192:
print local "3 ";
goto start193
start191:
print local "2 ";
goto start192
start190:
print local "1 ";
goto start191
start189:
print local "10"
goto start190
start188:
print local "9 ";
goto start189
start187:
print local "8 ";
goto start188
start186:
print local "7 ";
goto start187
start185:
print local "6 ";
goto start186
start184:
print local "5 ";
goto start185
start183:
print local "4 ";
goto start184
start182:
print local "3 ";
goto start183
start181:
print local "2 ";
goto start182
start180:
print local "1 ";
goto start181
start179:
print local "10"
goto start180
start178:
print local "9 ";
goto start179
start177:
print local "8 ";
goto start178
start176:
print local "7 ";
goto start177
start175:
print local "6 ";
goto start176
start174:
print local "5 ";
goto start175
start173:
print local "4 ";
goto start174
start172:
print local "3 ";
goto start173
start171:
print local "2 ";
goto start172
start170:
print local "1 ";
goto start171
start169:
print local "10"
goto start170
start168:
print local "9 ";
goto start169
start167:
print local "8 ";
goto start168
start166:
print local "7 ";
goto start167
start165:
print local "6 ";
goto start166
start164:
print local "5 ";
goto start165
start163:
print local "4 ";
goto start164
start162:
print local "3 ";
goto start163
start161:
print local "2 ";
goto start162
start160:
print local "1 ";
goto start161
start159:
print local "10"
goto start160
start158:
print local "9 ";
goto start159
start157:
print local "8 ";
goto start158
start156:
print local "7 ";
goto start157
start155:
print local "6 ";
goto start156
start154:
print local "5 ";
goto start155
start153:
print local "4 ";
goto start154
start152:
print local "3 ";
goto start153
start151:
print local "2 ";
goto start152
start150:
print local "1 ";
goto start151
start149:
print local "10"
goto start150
start148:
print local "9 ";
goto start149
start147:
print local "8 ";
goto start148
start146:
print local "7 ";
goto start147
start145:
print local "6 ";
goto start146
start144:
print local "5 ";
goto start145
start143:
print local "4 ";
goto start144
start142:
print local "3 ";
goto start143
start141:
print local "2 ";
goto start142
start140:
print local "1 ";
goto start141
start139:
print local "10"
goto start140
start138:
print local "9 ";
goto start139
start137:
print local "8 ";
goto start138
start136:
print local "7 ";
goto start137
start135:
print local "6 ";
goto start136
start134:
print local "5 ";
goto start135
start133:
print local "4 ";
goto start134
start132:
print local "3 ";
goto start133
start131:
print local "2 ";
goto start132
start130:
print local "1 ";
goto start131
start129:
print local "10"
goto start130
start128:
print local "9 ";
goto start129
start127:
print local "8 ";
goto start128
start126:
print local "7 ";
goto start127
start125:
print local "6 ";
goto start126
start124:
print local "5 ";
goto start125
start123:
print local "4 ";
goto start124
start122:
print local "3 ";
goto start123
start121:
print local "2 ";
goto start122
start120:
print local "1 ";
goto start121
start119:
print local "10"
goto start120
start118:
print local "9 ";
goto start119
start117:
print local "8 ";
goto start118
start116:
print local "7 ";
goto start117
start115:
print local "6 ";
goto start116
start114:
print local "5 ";
goto start115
start113:
print local "4 ";
goto start114
start112:
print local "3 ";
goto start113
start111:
print local "2 ";
goto start112
start110:
print local "1 ";
goto start111
start109:
print local "10"
goto start110
start108:
print local "9 ";
goto start109
start107:
print local "8 ";
goto start108
start106:
print local "7 ";
goto start107
start105:
print local "6 ";
goto start106
start104:
print local "5 ";
goto start105
start103:
print local "4 ";
goto start104
start102:
print local "3 ";
goto start103
start101:
print local "2 ";
goto start102
start100:
print local "1 ";
goto start101
start99:
print local "10"
goto start100
start98:
print local "9 ";
goto start99
start97:
print local "8 ";
goto start98
start96:
print local "7 ";
goto start97
start95:
print local "6 ";
goto start96
start94:
print local "5 ";
goto start95
start93:
print local "4 ";
goto start94
start92:
print local "3 ";
goto start93
start91:
print local "2 ";
goto start92
start90:
print local "1 ";
goto start91
start89:
print local "10"
goto start90
start88:
print local "9 ";
goto start89
start87:
print local "8 ";
goto start88
start86:
print local "7 ";
goto start87
start85:
print local "6 ";
goto start86
start84:
print local "5 ";
goto start85
start83:
print local "4 ";
goto start84
start82:
print local "3 ";
goto start83
start81:
print local "2 ";
goto start82
start80:
print local "1 ";
goto start81
start79:
print local "10"
goto start80
start78:
print local "9 ";
goto start79
start77:
print local "8 ";
goto start78
start76:
print local "7 ";
goto start77
start75:
print local "6 ";
goto start76
start74:
print local "5 ";
goto start75
start73:
print local "4 ";
goto start74
start72:
print local "3 ";
goto start73
start71:
print local "2 ";
goto start72
start70:
print local "1 ";
goto start71
start69:
print local "10"
goto start70
start68:
print local "9 ";
goto start69
start67:
print local "8 ";
goto start68
start66:
print local "7 ";
goto start67
start65:
print local "6 ";
goto start66
start64:
print local "5 ";
goto start65
start63:
print local "4 ";
goto start64
start62:
print local "3 ";
goto start63
start61:
print local "2 ";
goto start62
start60:
print local "1 ";
goto start61
start59:
print local "10"
goto start60
start58:
print local "9 ";
goto start59
start57:
print local "8 ";
goto start58
start56:
print local "7 ";
goto start57
start55:
print local "6 ";
goto start56
start54:
print local "5 ";
goto start55
start53:
print local "4 ";
goto start54
start52:
print local "3 ";
goto start53
start51:
print local "2 ";
goto start52
start50:
print local "1 ";
goto start51
start49:
print local "10"
goto start50
start48:
print local "9 ";
goto start49
start47:
print local "8 ";
goto start48
start46:
print local "7 ";
goto start47
start45:
print local "6 ";
goto start46
start44:
print local "5 ";
goto start45
start43:
print local "4 ";
goto start44
start42:
print local "3 ";
goto start43
start41:
print local "2 ";
goto start42
start40:
print local "1 ";
goto start41
start39:
print local "10"
goto start40
start38:
print local "9 ";
goto start39
start37:
print local "8 ";
goto start38
start36:
print local "7 ";
goto start37
start35:
print local "6 ";
goto start36
start34:
print local "5 ";
goto start35
start33:
print local "4 ";
goto start34
start32:
print local "3 ";
goto start33
start31:
print local "2 ";
goto start32
start30:
print local "1 ";
goto start31
start29:
print local "10"
goto start30
start28:
print local "9 ";
goto start29
start27:
print local "8 ";
goto start28
start26:
print local "7 ";
goto start27
start25:
print local "6 ";
goto start26
start24:
print local "5 ";
goto start25
start23:
print local "4 ";
goto start24
start22:
print local "3 ";
goto start23
start21:
print local "2 ";
goto start22
start20:
print local "1 ";
goto start21
start19:
print local "10"
goto start20
start18:
print local "9 ";
goto start19
start17:
print local "8 ";
goto start18
start16:
print local "7 ";
goto start17
start15:
print local "6 ";
goto start16
start14:
print local "5 ";
goto start15
start13:
print local "4 ";
goto start14
start12:
print local "3 ";
goto start13
start11:
print local "2 ";
goto start12
start10:
print local "1 ";
goto start11
start9:
print local "10"
goto start10
start8:
print local "9 ";
goto start9
start7:
print local "8 ";
goto start8
start6:
print local "7 ";
goto start7
start5:
print local "6 ";
goto start6
start4:
print local "5 ";
goto start5
start3:
print local "4 ";
goto start4
start2:
print local "3 ";
goto start3
start1:
print local "2 ";
goto start2
start:
print local "1 ";
goto start1
anykey:
ask local "\nPress <RETURN> continue.", i$
cls
return